﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ZSZ.Core.Entities;

namespace ZSZ.EntityFramework.ModelConfig
{
    class AttachmentConfig:EntityTypeConfiguration<AttachmentEntity>
    {
        //public AttachmentConfig()
        //{
        //    ToTable("T_Attachments");
        //    //多对多WithMany不能空
        //    HasMany(a => a.Houses).WithMany(a=>a.Attachments).Map(m=>m.ToTable("T_HouseAttachments")
        //        .MapLeftKey("AttachmentId").MapRightKey("HouseId"));
        //    Property(e => e.IconName).IsRequired().HasMaxLength(50).IsUnicode(false);
        //    Property(e => e.Name).IsRequired().HasMaxLength(50);
        //}

        public override void Map(EntityTypeBuilder<AttachmentEntity> builder)
        {

            builder.ToTable("T_Attachments");

            builder.Property(e => e.IconName).IsRequired().HasMaxLength(50).IsUnicode(false);
            builder.Property(e => e.Name).IsRequired().HasMaxLength(50);

        }
    }
}
